#pragma once

#include <linux/types.h>
#include <linux/cpuhotplug.h>
#include <linux/completion.h>

#include "cpuhplock.h"

struct task_struct;

struct cpuhp_cpu_state
{
    enum cpuhp_state state;
    enum cpuhp_state target;
    enum cpuhp_state fail;

#ifdef CONFIG_SMP
    struct task_struct *thread;
    bool should_run;
    bool rollback;
    bool single;
    bool bringup;
    struct hlist_node *node;
    struct hlist_node *last;
    enum cpuhp_state cb_state;
    int result;
    atomic_t ap_sync_state;
    struct completion done_up;
    struct completion done_down;
#endif
};

struct cpuhp_cpu_state *per_cpuhp_cpu_state(unsigned int cpu);

void cpuhp_invoke_callback_range_nofail(bool bringup,
                                        unsigned int cpu,
                                        struct cpuhp_cpu_state *st,
                                        enum cpuhp_state target);
